<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Redis 热点 Key 问题深度解析</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
        }
        
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            position: relative;
            overflow: hidden;
        }
        
        .hero-gradient::before {
            content: '';
            position: absolute;
            top: -50%;
            right: -50%;
            bottom: -50%;
            left: -50%;
            background: radial-gradient(circle, rgba(255,255,255,0.1) 1px, transparent 1px);
            background-size: 50px 50px;
            animation: drift 20s linear infinite;
        }
        
        @keyframes drift {
            from { transform: translate(0, 0); }
            to { transform: translate(50px, 50px); }
        }
        
        .content-card {
            background: rgba(255, 255, 255, 0.95);
            backdrop-filter: blur(10px);
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
            transition: all 0.3s ease;
        }
        
        .content-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 25px 50px rgba(0, 0, 0, 0.15);
        }
        
        .section-title {
            position: relative;
            padding-left: 20px;
        }
        
        .section-title::before {
            content: '';
            position: absolute;
            left: 0;
            top: 50%;
            transform: translateY(-50%);
            width: 4px;
            height: 80%;
            background: linear-gradient(to bottom, #667eea, #764ba2);
            border-radius: 2px;
        }
        
        .highlight-box {
            background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
            color: white;
            padding: 20px;
            border-radius: 12px;
            margin: 20px 0;
            position: relative;
            overflow: hidden;
        }
        
        .highlight-box::after {
            content: '';
            position: absolute;
            top: -50%;
            right: -50%;
            width: 200%;
            height: 200%;
            background: radial-gradient(circle, rgba(255,255,255,0.2) 0%, transparent 70%);
            animation: pulse 3s ease-in-out infinite;
        }
        
        @keyframes pulse {
            0%, 100% { transform: scale(0.8); opacity: 0; }
            50% { transform: scale(1.2); opacity: 1; }
        }
        
        .feature-icon {
            width: 60px;
            height: 60px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            border-radius: 16px;
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            font-size: 24px;
            margin-bottom: 16px;
            transition: all 0.3s ease;
        }
        
        .feature-icon:hover {
            transform: rotate(10deg) scale(1.1);
        }
        
        .mermaid {
            background: white;
            padding: 20px;
            border-radius: 12px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
        }
        
        .drop-cap {
            float: left;
            font-size: 4em;
            line-height: 0.8;
            margin: 0 8px 0 0;
            font-weight: 700;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            font-family: 'Noto Serif SC', serif;
        }
        
        .solution-card {
            background: white;
            border-radius: 16px;
            padding: 24px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
            transition: all 0.3s ease;
            border: 2px solid transparent;
        }
        
        .solution-card:hover {
            border-color: #667eea;
            transform: translateY(-5px);
            box-shadow: 0 15px 40px rgba(102, 126, 234, 0.2);
        }
        
        .number-badge {
            width: 40px;
            height: 40px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: 700;
            font-size: 18px;
            margin-bottom: 16px;
        }
    </style>
</head>
<body>
    <!-- Hero Section -->
    <div class="hero-gradient text-white py-20 relative">
        <div class="container mx-auto px-6 relative z-10">
            <div class="max-w-4xl mx-auto text-center">
                <h1 class="text-5xl md:text-6xl font-bold mb-6 leading-tight">
                    Redis 热点 Key 问题
                    <span class="block text-3xl md:text-4xl mt-4 font-light opacity-90">深度解析与解决方案</span>
                </h1>
                <p class="text-xl md:text-2xl opacity-90 leading-relaxed">
                    当某些键被频繁访问，而其他键访问较少时，<br class="hidden md:block">
                    这种不均衡的访问模式会对 Redis 性能产生显著影响
                </p>
                <div class="mt-10 flex justify-center space-x-8">
                    <div class="text-center">
                        <i class="fas fa-fire text-4xl mb-2"></i>
                        <p class="text-sm opacity-80">热点识别</p>
                    </div>
                    <div class="text-center">
                        <i class="fas fa-chart-line text-4xl mb-2"></i>
                        <p class="text-sm opacity-80">性能优化</p>
                    </div>
                    <div class="text-center">
                        <i class="fas fa-balance-scale text-4xl mb-2"></i>
                        <p class="text-sm opacity-80">负载均衡</p>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Main Content -->
    <div class="container mx-auto px-6 py-12">
        <!-- Problem Definition Section -->
        <div class="content-card rounded-2xl p-8 md:p-12 mb-12">
            <h2 class="section-title text-3xl font-bold text-gray-800 mb-8">
                <i class="fas fa-exclamation-triangle text-yellow-500 mr-3"></i>
                热点 Key 问题的定义
            </h2>
            
            <div class="prose max-w-none">
                <p class="text-lg text-gray-700 leading-relaxed mb-6">
                    <span class="drop-cap">R</span>edis 的热点 key 问题指的是在 Redis 实例中，有一些特定的键（key）被频繁访问，而其他键的访问则相对较少。这种不均衡的访问模式会对 Redis 的性能产生显著影响。
                </p>
            </div>

            <div class="grid md:grid-cols-2 gap-6 mt-8">
                <div class="solution-card">
                    <div class="feature-icon">
                        <i class="fas fa-database"></i>
                    </div>
                    <h3 class="text-xl font-bold text-gray-800 mb-3">单个键被频繁访问</h3>
                    <p class="text-gray-600">某个特定的键（如缓存的热门数据）被大量请求，这可能导致该键的处理成为性能瓶颈。</p>
                </div>
                
                <div class="solution-card">
                    <div class="feature-icon">
                        <i class="fas fa-network-wired"></i>
                    </div>
                    <h3 class="text-xl font-bold text-gray-800 mb-3">负载不均衡</h3>
                    <p class="text-gray-600">Redis 实例的负载不均衡，某些键的请求集中在少数节点上，导致这些节点的负载过高。</p>
                </div>
            </div>
        </div>

        <!-- Impact Section -->
        <div class="highlight-box relative z-10">
            <h3 class="text-2xl font-bold mb-4">
                <i class="fas fa-bolt mr-2"></i>
                热点 Key 带来的影响
            </h3>
            <div class="grid md:grid-cols-3 gap-6 relative z-10">
                <div class="text-center">
                    <i class="fas fa-tachometer-alt text-4xl mb-3"></i>
                    <h4 class="font-bold mb-2">性能下降</h4>
                    <p class="text-sm opacity-90">热点 key 的频繁访问会占用 Redis 的大量计算和 I/O 资源</p>
                </div>
                <div class="text-center">
                    <i class="fas fa-server text-4xl mb-3"></i>
                    <h4 class="font-bold mb-2">节点过载</h4>
                    <p class="text-sm opacity-90">请求集中在某些节点上，造成资源浪费和不稳定性</p>
                </div>
                <div class="text-center">
                    <i class="fas fa-times-circle text-4xl mb-3"></i>
                    <h4 class="font-bold mb-2">缓存失效</h4>
                    <p class="text-sm opacity-90">高并发下可能导致缓存穿透，从而导致性能下降</p>
                </div>
            </div>
        </div>

        <!-- Solutions Section -->
        <div class="content-card rounded-2xl p-8 md:p-12 mt-12">
            <h2 class="section-title text-3xl font-bold text-gray-800 mb-8">
                <i class="fas fa-tools text-blue-500 mr-3"></i>
                如何处理热点 Key 问题
            </h2>

            <div class="space-y-8">
                <!-- Solution 1 -->
                <div class="solution-card">
                    <div class="number-badge">1</div>
                    <h3 class="text-xl font-bold text-gray-800 mb-4">分析和识别热点 key</h3>
                    <div class="grid md:grid-cols-2 gap-4">
                        <div class="flex items-start">
                            <i class="fas fa-chart-bar text-purple-500 mt-1 mr-3"></i>
                            <div>
                                <h4 class="font-semibold text-gray-700">使用监控工具</h4>
                                <p class="text-gray-600 text-sm">利用 MONITOR、INFO 命令或 RedisInsight 等工具识别高频访问键</p>
                            </div>
                        </div>
                        <div class="flex items-start">
                            <i class="fas fa-file-alt text-purple-500 mt-1 mr-3"></i>
                            <div>
                                <h4 class="font-semibold text-gray-700">日志分析</h4>
                                <p class="text-gray-600 text-sm">通过 ELK 堆栈等工具追踪热点 key 的访问情况</p>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- Solution 2 -->
                <div class="solution-card">
                    <div class="number-badge">2</div>
                    <h3 class="text-xl font-bold text-gray-800 mb-4">优化热点 key 处理</h3>
                    <div class="space-y-3">
                        <div class="flex items-start">
                            <i class="fas fa-filter text-green-500 mt-1 mr-3"></i>
                            <div>
                                <h4 class="font-semibold text-gray-700">缓存穿透处理</h4>
                                <p class="text-gray-600 text-sm">使用布隆过滤器等技术避免无效请求对 Redis 的影响</p>
                            </div>
                        </div>
                        <div class="flex items-start">
                            <i class="fas fa-puzzle-piece text-green-500 mt-1 mr-3"></i>
                            <div>
                                <h4 class="font-semibold text-gray-700">数据分片</h4>
                                <p class="text-gray-600 text-sm">将热点数据拆分成多个子数据或分布到不同分片上</p>
                            </div>
                        </div>
                        <div class="flex items-start">
                            <i class="fas fa-level-down-alt text-green-500 mt-1 mr-3"></i>
                            <div>
                                <h4 class="font-semibold text-gray-700">数据降级</h4>
                                <p class="text-gray-600 text-sm